// src/main/java/com/techchat/backend/controller/HistoryController.java

package com.techchat.backend.controller;

import com.techchat.backend.model.Message;
import com.techchat.backend.service.MessageService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HistoryController {

    private final MessageService messageService;

    public HistoryController(MessageService messageService) {
        this.messageService = messageService;
    }

    /**
     * GET /api/history
     * 返回数据库中所有历史消息（按时间升序）
     */
    @GetMapping("/api/history")
    public List<Message> getHistory() {
        return messageService.getAllMessages();
    }
}
